/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.CnvtInfo;
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.dbaccess.DmMsgSend;
/*     */ import dm.sql.DmdbDateTime;
/*     */ import dm.sql.DmdbTime;
/*     */ import java.sql.Date;
/*     */ import java.sql.SQLException;
/*     */ import java.sql.Time;
/*     */ import java.sql.Timestamp;
/*     */ 
/*     */ public class DmShortBinder
/*     */   extends DmBinder
/*     */ {
/*     */   public DmShortBinder(DmdbPreparedStatement_bs pstmt)
/*     */   {
/*  19 */     super(pstmt);
/*     */   }
/*     */   
/*     */   void init()
/*     */   {
/*  24 */     this.recDType = 6;
/*  25 */     this.recPrec = 2;
/*  26 */     this.recScale = 0;
/*     */   }
/*     */   
/*     */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*     */   {
/*  31 */     short x = ((short[])this.pstmt.m_paramObjects[icol])[irow];
/*  32 */     String serverEncoding = this.pstmt.connection.getServerEncoding();
/*  33 */     CnvtInfo cnvtInfo = this.pstmt.connection.getCnvtInfo();
/*  34 */     short dbTz = cnvtInfo.getDbTz();
/*  35 */     short ltz = cnvtInfo.getTimeZone();
/*  36 */     byte[] ret = toDbBytes(x, this.destDType, this.destPrec, this.destScale, serverEncoding, ltz, dbTz);
/*     */     
/*  38 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*     */   }
/*     */   
/*     */   public static byte[] toDbBytes(short x, int destDType, int destPrec, int destScale, String serverEncoding, short ltz, short dbTz)
/*     */     throws SQLException
/*     */   {
/*  44 */     byte[] ret = null;
/*  45 */     switch (destDType)
/*     */     {
/*     */     case 6: 
/*  48 */       ret = Convertion.shortToByteArray(x);
/*  49 */       break;
/*     */     case 3: 
/*     */     case 13: 
/*  52 */       ret = Convertion.booleanToByteArray(x != 0);
/*  53 */       break;
/*     */     case 5: 
/*  55 */       if ((x > 127) || (x < -128)) {
/*  56 */         DBError.throwSQLException(6004);
/*     */       }
/*  58 */       ret = Convertion.byteToByteArray((byte)x);
/*  59 */       break;
/*     */     case 7: 
/*  61 */       ret = Convertion.IntToByteArray(x);
/*  62 */       break;
/*     */     case 8: 
/*  64 */       ret = Convertion.longToByteArray(x);
/*  65 */       break;
/*     */     case 10: 
/*  67 */       ret = Convertion.floatToByteArray(x);
/*  68 */       break;
/*     */     case 11: 
/*  70 */       ret = Convertion.doubleToByteArray(x);
/*  71 */       break;
/*     */     case 9: 
/*     */     case 24: 
/*  74 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), destPrec, destScale);
/*  75 */       break;
/*     */     case 0: 
/*     */     case 1: 
/*  78 */       ret = Convertion.String_char_2CType(String.valueOf(x), destPrec, destDType, serverEncoding);
/*  79 */       break;
/*     */     case 2: 
/*     */     case 19: 
/*  82 */       ret = 
/*  83 */         Convertion.String_varchar_2CType(String.valueOf(x), destPrec, destDType, serverEncoding);
/*  84 */       break;
/*     */     
/*     */     case 16: 
/*  87 */       if (x > 255611203200L) {
/*  88 */         DBError.throwSQLException(63024);
/*     */       }
/*  90 */       DmdbDateTime ts = new DmdbDateTime(new Timestamp(x * 1000 - 
/*  91 */         2209017600000L).toString(), destScale, 2);
/*  92 */       ret = Convertion.TimeStampToByteArray(ts, destDType, destScale, dbTz, ltz);
/*  93 */       break;
/*     */     
/*     */     case 15: 
/*  96 */       ret = Convertion.TimeToByteArray(new DmdbTime(String.valueOf(new Time(x * 1000)), 
/*  97 */         destScale));
/*  98 */       break;
/*     */     
/*     */     case 14: 
/* 101 */       if (x > 2958463L) {
/* 102 */         DBError.throwSQLException(63024);
/*     */       }
/* 104 */       DmdbDateTime dt = new DmdbDateTime(new Date(x * 24 * 60 * 60 * 1000 - 
/* 105 */         2209017600000L).toString(), destScale, 0);
/* 106 */       ret = Convertion.DateToByteArray(dt);
/* 107 */       break;
/*     */     case 4: case 12: case 17: case 18: case 20: case 21: case 22: case 23: default: 
/* 109 */       DBError.throwSQLException(6007);
/*     */     }
/* 111 */     return ret;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmShortBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */